﻿@model Resto.CostControl.Core.Facade.DishModule.DataTransferObject.DishDTO           
@using Resto.CostControl.WebControl.DWZAdapter
<div class="pageContent">
    @using (Html.DWZBeginForm())
    { 
        <div class="pageFormContent" layouth="56">
            @Html.HiddenFor(model => model.ID)
            @Html.DWZTextBoxFor(model => model.Name).Required()
            @Html.DWZTextBoxFor(model => model.Code).Required()
            @Html.DWZTextBoxFor(model => model.Cost).Number().Required()
            @Html.DWZDropDownListFor(model => model.Category, "DishCategory").Required()
            @Html.DWZTextBoxFor(model => model.Price).Number().Required()
            @Html.DWZDropDownListFor(model => model.MainMaterialCategory, "MainMaterialCategory").Required()
            @Html.DWZDropDownListFor(model => model.CookType, "CookType").Required()
            <div class="divider">
            </div>
            <div class="tabs">
                <div class="tabsContent" style="height: 260px;">
                    <table class="list nowrap itemDetail" addbutton="增加品名" width="97%">
                        <thead>
                            <tr>
                                <th type="lookup" name="dwz.items[#index#].MaterialName" size="15" lookupgroup="items[#index#]" 
                            lookupurl="@Url.Action("LookupMaterial", "Material")" lookupPk="MaterialId"  fieldclass="required">
                                    品名名称
                                </th>
                                <th type="text" name="dwz.items[#index#].Weight" size="10" fieldclass="number">
                                    每份克重
                                </th>
                                <th type="del" width="25">
                                    <hi:text key="操作" />
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (!string.IsNullOrEmpty(Model.ID))
                            {
                                var items = new Resto.CostControl.Core.Facade.DishModule.FacadeObject.DishFO().GetDishMaterialDTOArray(Model.ID);
                                for (int index = 0; index < items.Length; index++)
                                {
                                    Resto.CostControl.Core.Facade.DishModule.DataTransferObject.DishMaterialDTO item = items.ElementAt(index);
                                <tr class="unitBox">
                                    <td>
                                        @Html.Hidden("items[" + index + "].MaterialId", item.MaterialId)
                                        @Html.TextBox("dwz.items[" + index + "].MaterialName", item.MaterialName, new { size = "15" })
                                        <a title="查找带回" lookupPk="MaterialId" lookupgroup="items[@index]" href="@Url.Action("LookupMaterial", "Material")" class="btnLook">
                                            查找带回</a>
                                    </td>
                                    <td>
                                        @Html.TextBox("dwz.items[" + index + "].Weight", item.Weight, new { size = "10" })
                                    </td>
                                    <td>
                                        <a href="@Url.Action("DeleteItem")/@item.MaterialId" class="btnDel" title="您确定要删除服务端的记录吗?">
                                            删除</a>
                                    </td>
                                </tr>
                                }
                            }
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        @Html.DWZFormBar()
    }
</div>
